home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 4.4 KB | 136 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGATextEdit.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant Text Edit Field
- // Copyright © 1996 Chrisoft (Christophe ANDRES) All rights reserved.
- //
- // You may use this source code in any application (commercial, shareware, freeware,
- // postcardware, etc), but not remove this notice (no need to acknowledge the use of
- // this class in the about box)
- // You may not sell this source code in any form. This source code may be placed on
- // publicly accessable archive sites and source code disks. It may not be placed on
- // profit archive sites and source code disks without the permission of the author,
- // Christophe ANDRES.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- //
- // If you make any change or improvement on this class, please send the improved/changed
- // version to : chrisoft@calva.net or Christophe ANDRES
- // 20, rue Prosper Mérimée
- // 67100 STRASBOURG
- // FRANCE
- //
- // ===========================================================================
- // LAGATextEdit.h <- double-click + Command-D to see class declaration
- //
- // LAGATextEdit is my implementation of the “Apple Grayscale Appearance for System 7.5”
- // Text Edit field. It is designed to work effectively with a class like LAGAIndexTab.
- // In an index tab, a Text Edit Field can be present but in another Index Tab, and should
- // therefore not be selected when the user presses the “Tab” key. Also if the Index Tab is
- // changed and a Text Entry Field is revealed it should be selected. LAGATextEdit handles
- // all these cases.
- // LAGATextEdit keeps its own background in white, whatever the window background may be.
- //
- // Version : 1.2
- //
- // Change History (most recent first, date in US form : mm/dd/yy):
- //
- // 06/30/96 ca Public release of version 1.2
- // 06/04/96 ca Added RegisterClass method to ease registry
- // Increased version to 1.2
- // 05/20/96 ca Increased version to 1.1
- // Added "on the fly" constructor
- // Added change history
- // 04/22/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.0)
- //
- // To Do:
- //
-
- #include "LAGATextEdit.h"
- #include <UDrawingState.h>
-
- // begin <06/04/96 ca>
- void LAGATextEdit::RegisterClass ()
-
- {
- URegistrar::RegisterClass(LAGATextEdit::class_ID, (ClassCreatorFunc)LAGATextEdit::CreateAGATextEditStream);
- }
- // end <06/04/96 ca>
-
- LAGATextEdit* LAGATextEdit::CreateAGATextEditStream (LStream *inStream)
-
- {
- return(new LAGATextEdit(inStream));
- }
-
- //-------Constructors-------------------------------------------------------------------------------------------------
-
- LAGATextEdit::LAGATextEdit (LStream *inStream) : LTextEdit (inStream)
-
- {
- }
-
- LAGATextEdit::LAGATextEdit (const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo,
- Uint16 inTextAttributes, ResIDT inTextTraitsID)
- : LTextEdit(inPaneInfo, inViewInfo, inTextAttributes, inTextTraitsID)
- {
- }
-
- Boolean LAGATextEdit::ObeyCommand (CommandT inCommand, void* ioParam)
-
- {
- Boolean cmdHandled = true;
-
- switch (inCommand)
- {
- case msg_TabSelect : // Often LAGATextEdit items can be in tab index views and we need to be seen to be selected
- if (!IsEnabled())
- cmdHandled = false;
- else
- if (mSuperView != nil)
- {
- Rect frame;
- Rect revealedRect;
-
- CalcPortFrameRect(frame);
- mSuperView->GetRevealedRect(revealedRect);
- cmdHandled = ::SectRect(&revealedRect, &frame, &revealedRect);
- }
- if (!cmdHandled)
- break; // else fall thru to default case
- default:
- cmdHandled = LTextEdit::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- void LAGATextEdit::SpendTime (const EventRecord &inMacEvent)
-
- {
- if (FocusDraw() & IsVisible() & HasAttribute(textAttr_Selectable))
- {
- ::TEIdle(mTextEditH);
- }
- else
- SwitchTarget(GetSuperCommander());
- }
-
- void LAGATextEdit::DrawSelf ()
-
- {
- Rect frame;
- StColorState saveColors;
-
- CalcLocalFrameRect(frame);
-
- ::BackColor(whiteColor);
- ::EraseRect(&frame);
-
- LTextEdit::DrawSelf();
- }
-